//
//  TapePlayerView.m
//  MansApp
//
//  Created by lanou3g on 15/7/29.
//  Copyright (c) 2015年 ACH. All rights reserved.
//

#import "TapePlayerView.h"

@implementation TapePlayerView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
        GroundGlass *glass = [[GroundGlass alloc]initWithFrame:self.bounds style:UIBlurEffectStyleDark];
        glass.image = [UIImage imageNamed:@"page"];
        self.progress = [[UIProgressView alloc]initWithProgressViewStyle:UIProgressViewStyleDefault];
        self.progress.frame = CGRectMake(0, kP6Height(30), kWidth, kP6Height(40));
        self.progress.progressTintColor = [UIColor colorWithRed:143 / 255.0 green:122 / 255.0 blue:16 / 255.0 alpha:1];
        self.progress.trackTintColor = [UIColor orangeColor];
        
        self.beginLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, kP6Height(80), kP6Height(30))];
        self.beginLabel.textColor = [UIColor colorWithRed:102/255.0 green:205/255.0 blue:170/255.0 alpha:1];
        self.beginLabel.font = [UIFont fontWithName:@"DBLCDTempBlack" size:20];
        self.beginLabel.text = @"0:0";
        self.beginLabel.textAlignment = NSTextAlignmentCenter;
        self.endLabel = [[UILabel alloc]initWithFrame:CGRectMake(kWidth - kP6Height(80), 0, kP6Height(80), kP6Height(30))];
        self.endLabel.text = @"0:0";
        self.endLabel.font = [UIFont fontWithName:@"DBLCDTempBlack" size:20];
        self.endLabel.textAlignment = NSTextAlignmentCenter;
        
        self.endLabel.textColor = [UIColor colorWithRed:102/255.0 green:205/255.0 blue:170/255.0 alpha:1];
        
        self.playButton = [UIButton buttonWithType:UIButtonTypeSystem];
        self.playButton.frame = CGRectMake( kP6Height(80), kP6Height(70), kP6Height(60), kP6Height(60));
        self.playButton.showsTouchWhenHighlighted = YES;
        [self.playButton setBackgroundImage:[UIImage imageNamed:@"cm2_btn_play@3x"] forState:UIControlStateNormal ];
        
        self.pauseButton = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.pauseButton setBackgroundImage:[UIImage imageNamed:@"cm2_btn_pause@3x"] forState:UIControlStateNormal ];
        self.pauseButton.frame = CGRectMake(self.playButton.frame.origin.x + self.playButton.bounds.size.width + kP6width(17.5), kP6Height(70), kP6Height(60), kP6Height(60));
        self.pauseButton.showsTouchWhenHighlighted = YES;
        
        
        self.stopButton = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.stopButton setBackgroundImage:[UIImage imageNamed:@"cm2_navigation_btn_close@3x"] forState:UIControlStateNormal ];
        self.stopButton.frame = CGRectMake(self.pauseButton.frame.origin.x + self.pauseButton.bounds.size.width + kP6width(17.5), kP6Height(70), kP6Height(60), kP6Height(60));
        self.stopButton.showsTouchWhenHighlighted = YES;
        

        
        
        
        self.playButton.tag = 100;
        self.pauseButton.tag = 101;
        self.stopButton.tag = 102;
        
        
        
        [self addSubview: glass];
        [self addSubview:self.beginLabel];
        [self addSubview:self.endLabel];
        [self addSubview: self.progress];
        
        [self addSubview:self.playButton];
        [self addSubview:self.pauseButton];
        [self addSubview:self.stopButton];
        
   
    }
    return self;
}

- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents{
  
    [self.playButton addTarget:target action:action forControlEvents:controlEvents];
    [self.pauseButton addTarget:target action:action forControlEvents:controlEvents];
    [self.stopButton addTarget:target action:action forControlEvents:controlEvents];
    
}


@end
